﻿@model HelloMinasan.Web.Song.ViewModels.SongViewModels
<link href="~/Content/Site.css" rel="stylesheet" />
<script>
    function approveLyric(id, type) {
        $.ajax(
            {
                type: "POST",
                url: "/Admin/ApproveLyric",
                data: { lyricId: id, typeAction : type },
                success: function (result) {
                    $.msgbox(result.Message, { type: "info" });
                    showLyrics(@Model.SongId);
            }
        });
    }
</script>
<div id="lyricRegionSection">
    @{ bool isFirstLanguage = true;}
    @foreach (var item in Model.Song.LyricDetails)
    {
        if (isFirstLanguage)
        {
        @Html.Raw("<div class=\"titleSection\" id=\"lyricTitle-" + item.SongId + "-" + item.LanguageId + "\" style=\"color:red\" onclick=\"showHideLyricSection(\'lyric-" + item.SongId + "-" + item.LanguageId + "\', this, 0)\">")
            isFirstLanguage = false;
        }
        else
        {
        @Html.Raw("<div class=\"titleSection\" id=\"lyricTitle-" + item.SongId + "-" + item.LanguageId + "\" onclick=\"showHideLyricSection(\'lyric-" + item.SongId + "-" + item.LanguageId + "\', this, 0)\">")
        }
        if (item.IsOrginal)
        {
        <img src="@Url.Content("~/Content/Images/rosette.png")" width="20" height="20"/>
        }
        else
        {
        <img src="@Url.Content("~/Content/Images/composer.png")" width="20" height="20"/>}
        <span class="titleTab">@item.Language.Name.Substring(0, 2).ToUpper()</span>
        if ((!item.LyricStatus && item.CanUpdate && Request.IsAuthenticated) || User.Identity.Name == "admin")
        {
        <a id="edit-@item.SongId-@item.LanguageId" onclick="communityEditLyric(this, @item.SongId , @item.LanguageId)">
            <img src="@Url.Content("~/Content/Images/allowEdit.png")" title="Edit this lyric." width="15" /></a>
        <a id="save-@item.SongId-@item.LanguageId" class="toggleButton" onclick="communitySaveLyric(this, @item.SongId , @item.LanguageId)">
            <img src="@Url.Content("~/Content/Images/save.png")" title="Edit this lyric." width="15" /></a>
        <a id="cancel-@item.SongId-@item.LanguageId" class="toggleButton" onclick="communityCancelLyric(this, @item.SongId , @item.LanguageId)">
            <img src="@Url.Content("~/Content/Images/cancel.png")" title="Cancel." width="15" /></a>
        }
        <div class="tooltipContent">
            @if (!item.LyricStatus)
            {
                <a href="#" onclick="approveLyric(@item.ID, true)">
                    <img src="/Content/Images/approve.png" />
                    <text>Approve this lyric</text>
                </a>
            }
            else
            {
                <a href="#" onclick="approveLyric(@item.ID, false)">
                    <img src="/Content/Images/unapprove.png" />
                    <text>Un-approve this lyric</text>
                </a>
            }
            <br />
            Language: <strong>@item.Language.Name </strong>
            <br />
            Last update by <strong>@item.UpdateUser</strong> on <strong>@item.LastUpdate.ToLongDateString()</strong>
        </div>
        @Html.Raw("</div>")
    }
    @if (Request.IsAuthenticated)
    {
        <div id="lyricTitle-0-0" class="titleSection" onclick="showHideLyricSection('lyric-0-0', this, @Model.Song.Id)">
            <img src="@Url.Content("~/Content/Images/document-new.png")" width="20" height="20"/>
            +
                                    <div class="tooltipContent">Add new lyric</div>
        </div>
    }
    @if (Model.Song.LyricDetails.Any())
    {
        bool isFirst = true;
        foreach (var item in Model.Song.LyricDetails)
        {
            if (isFirst)
            {
                if (!item.LyricStatus)
                {
        <textarea id="lyric-@item.SongId-@item.LanguageId" 
                                                readonly="readonly" class="lyricTextArea">@item.LyricContent</textarea>
                }
                else
                {
        <div id="lyric-@item.SongId-@item.LanguageId" class="lyricTextArea">
            @Html.Raw(item.LyricContent.Replace("\\r\\n", "<br>"))
        </div>
                }
                isFirst = false;
            }
            else
            {
        <textarea id="lyric-@item.SongId-@item.LanguageId" readonly="readonly" class="lyricTextArea" style="display:none">@item.LyricContent</textarea>
            }
        }
    }
    else
    {
        <div class="contentSectionInside">Currently, there is no lyric for this song. </div>
    }
    <div name="createNewLyricRegion" id="lyric-0-0" style="display: none">
        <textarea id="newLyricContentCommunity" class="lyricTextArea createLyric"></textarea>
        Please select language: <span id="comboboxLanguage"></span>
        <br />
        <input type="button" onclick="saveCommunityAddNewLyric(@Model.Song.Id)" value="Save" />
        @*<input onclick="cancelCommunityAddNewLyric()" type="button" value="Cancel" />*@
    </div>
    <div id="lyricUpdateIndicator" style="display: none">
        <img src="@Url.Content("~/Content/Images/loader.gif")" />
        <br />
        Please wait while us process your updating...
    </div>
</div>
